package staticProxy;

/**
 * @Author:zimmor
 * @Date: 2021/3/24 17:04
 * @Description 静态代理类
 * @version: 1.0.0
 */

public class PersonProxy extends Person {

    private Person target;

    public Person getTarget() {
        return target;
    }

    public void setTarget(Person target) {
        this.target = target;
    }

    @Override
    public String getName() {
        System.out.println(System.currentTimeMillis());
        return target.getName();
    }

    @Override
    public void setAge(String age) {
        System.out.println(System.currentTimeMillis()+"修改了age");
        target.setAge(age);
    }

    public static void main(String[] args) {
        Person person = new Person();
        person.setName("小明");
        person.setAge("2");
        PersonProxy personProxy = new PersonProxy();
        personProxy.setTarget(person);
        System.out.println(personProxy.getName());
        personProxy.setAge("9");
    }
}
